<html   xmlns="http://www.w3.org/1999/xhtml"
                xmlns:jsp="http://java.sun.com/JSP/Page"
                xmlns:f="http://java.sun.com/jsf/core"      
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                xmlns:ui="http://java.sun.com/jsf/facelets">
      
    <h:head>
        <title>Catalogue</title>
                <link rel="stylesheet" href="../styles/style.css" />
    </h:head>
        
        <body>
                <h:panelGroup rendered="#{loginBean.loginSucces}">
            <ui:include src="../includes/header.xhtml" />
        <ui:include src="../includes/menu.xhtml" />
        
        <div id="content">
                <h2>Catalogue</h2>
                        <h:form>
                        <div id="liste_films">
                                <c:forEach var="film" items="#{catalogueBean.filmsCatalogue}">
                                        <div class="film">
                                                <fieldset>
                                                <legend>#{film.titre}</legend>
                                                <div class="film_infos">
                                                        <!--div class="titre_film">#{film.titre}</div-->
                                                        <div class="synopsis_film elem_film">#{film.synopsis}</div>
                                                        <div class="date_film elem_film">Date de sortie : 
                                                        <h:outputText value="#{film.dateSortie}">
                                                                <f:convertDateTime type="date" pattern="yyyy/MM/dd" />
                                                        </h:outputText></div>
                                                        <div class="duree_film elem_film">Durée : #{film.duree} minutes</div>
                                                        <div class="real_film elem_film">Réalisé par : #{film.realisateur}</div>
                                                        <div class="acteurs_film elem_film">Avec : #{film.acteurs}</div>
                                                        <div class="genre_film elem_film">Genre : #{film.genre}</div>
                                                        <div class="nationalite_film elem_film">Nationalité : #{film.nationalite}</div>
                                                        <div class="rating_film elem_film">#{film.rating} / 5</div>
                                                </div>
                                        
                                                <div class="film_achat">
                                                        <h:commandButton value=" - " >
                                                                <f:ajax listener="#{catalogueBean.removeFilm(film.id)}" render="@all" />
                                                        </h:commandButton>
                                                        
                                                        <h:inputText value="#{catalogueBean.data[film.id]}"
                                                                converter="javax.faces.Integer"
                                                                size="2" 
                                                                readonly="true" />                              
                                                                                        
                                                        <h:commandButton value=" + " >
                                                                <f:ajax listener="#{catalogueBean.addFilm(film.id)}" render="@all" />
                                                        </h:commandButton>
                                                </div>
                                                
                                                <div class="clear"></div>
                                                </fieldset>
                                        </div>
                                </c:forEach>
                        </div>
        
                        <div id="barreAchat">
                                <div id="boutonAchat"><h:commandButton value="Acheter" action="#{catalogueBean.valideAchat}" /></div>
                                <div id="errorMessage"><h:outputText value="#{catalogueBean.errorMessage}" /></div>
                                <div id="nbFilmsWrap">
                                        <div id="texteNbFilms">Nombre de films dans le panier : </div>
                                        <div id="NbFilms">
                                                <h:outputText value="#{catalogueBean.nbFilmsDansPanier}" />
                                        </div>
                                </div>
                        </div>
                        <div class="clear"></div>
                        </h:form>
                </div>
                <ui:include src="../includes/footer.xhtml" />
                
        </h:panelGroup>
        
        <h:panelGroup rendered="#{!loginBean.loginSucces}">
                        <ui:include src="../includes/authError.xhtml" />        
        </h:panelGroup>
        </body>
</html>